# !usr/bin/env python
# -*- coding:utf-8 -*-
from multiprocessing import Process
from gevent import monkey

monkey.patch_all()
from socket import *


def client(ip, port):
    try:
        client = socket(AF_INET, SOCK_STREAM)
        client.connect((ip, port))
        while True:
            client.send('hello'.encode('utf-8'))
            data = client.recv(1024)
            print(data.decode('utf-8'))
    except Exception as e:
        print('关闭了', e)


if __name__ == '__main__':
    for i in range(10):
        p = Process(target=client, args=('127.0.0.1', 8081))
        p.start()
